package com.duxd.springsecurityfinal.springsecurityfinal.mvc.controller;

import com.duxd.springsecurityfinal.springsecurityfinal.annotation.NeedAuthentication;
import com.duxd.springsecurityfinal.springsecurityfinal.pojo.Student;
import com.duxd.springsecurityfinal.springsecurityfinal.response.Response;
import com.duxd.springsecurityfinal.springsecurityfinal.response.ResponseBuild;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * @author dong
 * @date 2022/1/9 0009
 */
@RestController
public class LoginController {

    @NeedAuthentication(need = false)
    @GetMapping(value = "/hello", produces = {"application/json;charset=UTF-8"})
    public Callable<Response<String>> say(){

        return () -> ResponseBuild.request_success.data("hello");
    }

    @PostMapping(value = "student", produces = {"application/json;charset=UTF-8"})
    public Response<Student> student(){
        return ResponseBuild.request_success
                .data(new Student("huxiuru","hafu"));
    }
}
